<!-- include tpl=head_lay -->
<div class="layui-card">

	<div class="layui-card-header">
		{lang通知模板内容}
		<button type="button" class="layui-btn layui-btn-sm fr" onclick="$.phpok.go('{url ctrl=email/}')">返回列表</button>
	</div>
	<form method="post" class="layui-form" action="{url ctrl=email func=setok/}" onsubmit="return check_save()">
		<input type="hidden" name="id" id="id" value="{$id}" />
		<div class="layui-card-body">
			<blockquote class="layui-elem-quote">
				{lang短信模板以标识：}<b class="layui-bg-red">sms_</b> {lang开头}{lang，}{lang发送的内容不带样式}<br/>
				{lang部分短信接口不支持内容，只允许使用变量参数，这时内容是一行一条格式是：变量名:模板变量}<br/>
				允许自定义的短信内容都有自身规范，建议使用阿里提供的短信<br/>
				短信长度不要超过<b class="layui-bg-red">50字</b>（请注意变量可能用到的长度）
			</blockquote>
			<div class="layui-btn-group test-table-operate-btn" style="margin-bottom: 10px;">
				<div class="layui-btn-group test-table-operate-btn" style="margin-bottom: 10px;">
					
				</div>
			</div>
			<!-- php:$identifier = $rs.identifier ? $rs.identifier : ($type == 'sms' ? 'sms_' : 'email_') -->
			<div class="layui-form-item">
				<label class="layui-form-label">{lang标识}</label>
				<div class="layui-input-inline" style="width: 450px">
					<input type="text" id="identifier" name="identifier" value="{$identifier}" required lay-verify="required" autocomplete="off" class="layui-input" />
				</div>
				<div class="layui-form-mid layui-word-aux">
					{lang该标识用于调用}<!-- if $type == 'sms' -->{lang，}{lang短信模板请以：}<span class="red">sms_</span> {lang开头}<!-- else -->{lang禁止使用} sms_ {lang开头}<!-- /if -->
				</div>
			</div>
			<!-- if $type == 'sms' -->
			<div class="layui-form-item">
				<label class="layui-form-label">{lang模板标签}</label>
				<div class="layui-input-inline" style="width: 450px">
					<input type="text" id="title" name="title" value="{$rs.title}" required lay-verify="required" autocomplete="off" class="layui-input" />
				</div>
				<div class="layui-form-mid layui-word-aux">
					{lang适用于阿里云短信等需要使用标签的地方，使用标签后，内容将可能是无效的}
				</div>
			</div>
			<!-- else -->
			<div class="layui-form-item">
				<label class="layui-form-label">{lang邮件标题}</label>
				<div class="layui-input-inline" style="width: 450px">
					<input type="text" id="title" name="title" value="{$rs.title}" required lay-verify="required" autocomplete="off" class="layui-input" />
				</div>
				<div class="layui-form-mid layui-word-aux">
					{lang可以简单的使用PHPOK变量}
				</div>
			</div>
			<!-- /if -->
			<div class="layui-form-item">
				<label class="layui-form-label">{lang备注}</label>
				<div class="layui-input-inline" style="width: 450px">
					<input type="text" name="note" id="note" value="{$rs.note}" autocomplete="off" class="layui-input" />
				</div>
				<div class="layui-form-mid layui-word-aux">
					{lang对该模板内容的一些备注，建议使用您熟悉的语言}
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">{lang内容}</label>
				<div class="layui-input-inline" style="width: 80%">
					{$edit_content}
				</div>
			</div>
		</div>
		<div class="layui-form-item layui-layout-admin">
			<div class="layui-input-block">
				<div class="layui-footer"  style="left: 0;z-index:10">
					<button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</div>
	</form>
</div>
<script type="text/javascript">
    var type = "{$type}";
    function check_save()
    {
        var title = $("#title").val();
        if(!title){
            layui.alert("主题不能为空");
            return false;
        }
        var identifier = $("#identifier").val();
        if(!identifier){
            layui.alert("标识不能为空");
            return false;
        }
        if(type == "email"){
            if(identifier.substr(0,4) == 'sms_'){
                layui.alert('不能使用sms_做标识');
                return false;
            }
            var content = UE.getEditor('content').getContentTxt();
            if(!content){
                layui.alert("内容不能空");
                return false;
            }
        }else{
            if(identifier.substr(0,4) != 'sms_'){
                layui.alert('必须使用sms_做标识前缀');
                return false;
            }
        }
        var url = get_url("email","check") + "&identifier="+$.str.encode(identifier)+"&type="+type;
        var id = $("#id").val();
        if(id && id != "undefined" && id != "0"){
            url += "&id="+id;
        }
        var rs = $.phpok.json(url);
        if(rs.status != 'ok'){
            layui.alert(rs.content);
            return false;
        }
        $("#submit").attr("disabled",true);
        return true;
    }
</script>
<!-- include tpl=foot_lay -->
